package com.hdax.gulimall.order.web;


import com.alipay.api.AlipayApiException;
import com.hdax.gulimall.order.config.AlipayTemplate;
import com.hdax.gulimall.order.service.OrderService;
import com.hdax.gulimall.order.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class PayWebController {
    @Autowired
    private AlipayTemplate alipayConfig;

    @Autowired
    private OrderService orderService;

    @GetMapping(value = "/payOrder",produces = "text/html")
    @ResponseBody
    public String payOrder(@RequestParam("orderSn")String orderSn) throws AlipayApiException {
        PayVo payVo=orderService.getOrderPay(orderSn);
        String pay=alipayConfig.pay(payVo);
        return pay;
    }
}
